package com.wispx.gateway.core.http;

import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.Request;
import org.asynchttpclient.Response;

import java.util.concurrent.CompletableFuture;

public class HttpClient {

    private AsyncHttpClient asyncHttpClient;
    private static final HttpClient INSTANCE = new HttpClient();

    private HttpClient() {

    }

    public static HttpClient getInstance() {
        return INSTANCE;
    }

    public void initialized(AsyncHttpClient asyncHttpClient) {
        this.asyncHttpClient = asyncHttpClient;
    }

    public CompletableFuture<Response> executeRequest(Request request) {
        return asyncHttpClient.executeRequest(request).toCompletableFuture();
    }

}
